﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Model;
using System.Data.SqlClient;


namespace BLL
{
    public class DictionaryBLL
    {
        DictionaryDAL dal = new DictionaryDAL();

        /// <summary>
        /// 显示所有字典
        /// </summary>
        /// <returns></returns>
        public List<Dictionary> ShowDictionary()
        {
            return dal.Show();
        }


        //public List<Dictionary> ShowJu(string type,int id)
        //{
        //    List<Dictionary> DictionaryList=new List<Dictionary>();
        //    List<dynamic> list = DAL.EnumHelperDic.EnumListDic<DAL.EnumSelectType>(id, "请选择");
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        if (list[i].text == type)
        //        {
        //            return DAL.EnumHelperDic.GetEnumSelectState(list[i].text);
        //        }
        //    }
        //}


        /// <summary>
        /// 查找对应的字典信息
        /// </summary>
        /// <returns></returns>
        public List<Dictionary> ShowDictionary(string Dictionary_Type)
        {
            SqlParameter[] sp1 = new SqlParameter[]{
                  new SqlParameter("Dictionary_Type",Dictionary_Type)
            };

            return  dal.Show(sp1);
        }



        public List<Dictionary> PaperDictionary(int PageIndex, int PageSize, out int PageCount)
        {
            PageCount = dal.Show().Count();
            return dal.Show().Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }
        /// <summary>
        /// 添加字典
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool AddDictionary(Dictionary m)
        {
            return dal.Add(m);
        }
        /// <summary>
        /// 删除字典
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool DelDictionary(Dictionary m)
        {
            return dal.Del(m);
        }

        /// <summary>
        /// 查询单个字典信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Dictionary BackDictionary(int id)
        {
            return dal.Back(id);
        }

        /// <summary>
        /// 修改字典信息
        /// </summary>
        /// <param name="m"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdDictionary(Dictionary m, int id)
        {
            return dal.Update(m, id);
        }
    }
}
